package com.example.mall.client;

import com.example.mall.client.fallback.AuthFeignClientFactory;
import com.example.mall.domain.Login;
import com.example.mall.result.JSONResult;
import feign.Request;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author xxxli
 */
@FeignClient(value = "mall-service-auth",fallbackFactory = AuthFeignClientFactory.class,configuration = AuthFeignClient.FeignConfig.class)
public interface AuthFeignClient {

    @RequestMapping(value="/login/insert",method= RequestMethod.POST)
    public JSONResult insert(@RequestBody Login login);

    @Configuration
    public class FeignConfig {
        @Bean
        public Request.Options options() {
            return new Request.Options(10000, 60000); // 设置连接和读取超时时间
        }
    }
}
